package com.yuwj.chinaa.adapter;

import android.content.Context;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yuwj.chinaa.R;
import com.yuwj.chinaa.entity.EntityMiner;

import java.util.List;

/**
 * homeFragment里面的机器adapter
 */
public class HomeFragmentOreMachineAdapter extends BaseQuickAdapter<EntityMiner, BaseViewHolder> {
    Context context;

    public HomeFragmentOreMachineAdapter(Context context, List<EntityMiner> datas) {
        super(R.layout.item_ore_machine, datas);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, final EntityMiner item) {
        holder.setText(R.id.tv_ore_machine_type, item.getName() + "");
        holder.setText(R.id.tv_dangqsl, item.getUnitEfficiency() + "");
        holder.setText(R.id.tv_yis, item.getUsedEfficiency() + "");
        holder.setText(R.id.tv_zongsl, item.getTotalEfficiency() + "");
        holder.setText(R.id.tv_zongl, item.getMinerCount() + "");
        holder.setText(R.id.tv_shengy, item.getRemainMinerCount() + "");
        LinearLayout ll_container = holder.getView(R.id.ll_container);
        int index = holder.getLayoutPosition();
        if (index % 2 == 0) {
            ll_container.setBackgroundResource(R.mipmap.ic_home_fragment_ore_machine_bg_1);
        } else {
            ll_container.setBackgroundResource(R.mipmap.ic_home_fragment_ore_machine_bg_2);
        }
    }

}
